<%-- 
    Document   : ftpinfo
    Created on : Jun 6, 2011, 1:43:57 PM
    Author     : javauser
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>FTP Information</title>
        <script type="text/javascript">
            function MyMethod()
            {
                var check=true;
                var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
                var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
                
                var host=document.getElementById("host").value;
                if(host.length==0)
                {
                    document.getElementById("hostdiv").innerHTML="Please,Enter Host Name";
                    check=false;
                }
                else
                {
                    if(host.match(ipPattern))
                    {
                        check=true;
                    }
                    else
                    {
                        if(host.match(regexp))
                        {
                            check=true;
                        }
                        else
                        {
                            document.getElementById("hostdiv").innerHTML="Please,Enter Valid Host Name";
                            check=false;
                        }
                    }
                }
                
                var remotedir=document.getElementById("remotedir").value;		
                if(remotedir.length == 0)
                {		
                    document.getElementById("remotedirdiv").innerHTML="Please,Enter Valid Directory";
                    check=false;
                }
				
                var filename=document.getElementById("filename").value;
                if(filename.length==0)
                {
                    document.getElementById("filenamediv").innerHTML="Please,Enter File Name";
                    check=false;
                }
                                
                var fileextension=document.getElementById("fileextension").value;
                if(fileextension.length == 0)
                {
                    document.getElementById("fileextensiondiv").innerHTML="Please,Enter File Extension";
                    check=false;
                }
                                
                var username=document.getElementById("username").value;
                if(username.length==0)
                {
                    document.getElementById("usernamediv").innerHTML="Please,Enter User Name";
                    check=false;
                }
                                
                var localdir=document.getElementById("localdir").value;
                if(localdir.length==0)
                {
                    document.getElementById("localdirdiv").innerHTML="Please,Enter Valid Directory";
                    check=false;
                }
                return check;
            }
        </script>
    </head>
    <body>
        <table border="0" style="width:100%;" >
            <html:form action="/Next2" method="post" onsubmit="return MyMethod();" >
                <html:hidden property="index" value="ftpinfo"/>
                <tr>
                    <td colspan="3" align="center"><h2>Adding New provider (Step Two)</h2></td>
                </tr>
                <tr>
                    <td style="width:20%;" align="left"><b>Host Name(IP)</b></td>
                    <td style="width:30%;" align="left"><html:text property="host" styleId="host"></html:text></td>
                    <td style="width:50%;" align="left"><div id="hostdiv"><html:errors property="EmptyHost"/></div></td>
                </tr>
                <tr>
                    <td style="width:20%;" align="left"><b>Remote Directory</b></td>
                    <td style="width:30%;" align="left"><html:text property="remoteDir" styleId="remotedir"></html:text></td>
                    <td style="width:50%;" align="left"><div id="remotedirdiv"><html:errors property="EmptyRemoteDir"/><div></td>
                </tr>
                <tr>
                    <td style="width:20%;" align="left"><b>File Name</b></td>
                    <td style="width:30%;" align="left"><html:text property="fileName" styleId="filename"></html:text></td>
                    <td style="width:50%;" align="left"><div id="filenamediv"><html:errors property="EmptyFileName"/></div></td>
                </tr>
                <tr>
                   <td style="width:20%;" align="left"><b>File Extension</b></td>
                   <td style="width:30%;" align="left"><html:text property="fileExtension" styleId="fileextension"></html:text><label for="fileExtension">(i.e txt)</label></td>
                   <td style="width:50%;" align="left"><div id="fileextensiondiv"><html:errors property="EmptyFileExtension"/></div></td>
                </tr>
                <tr>
                   <td style="width:20%;" align="left"><b>User Name</b></td>
                   <td style="width:30%;" align="left"><html:text property="userName" styleId="username"></html:text></td>
                   <td style="width:50%;" align="left"><div id="usernamediv"><html:errors property="EmptyUserName"/></div></td>
                </tr>
                <tr>
                   <td style="width:20%;" align="left"><b>Password</b></td>
                   <td style="width:30%;" align="left"><html:password property="password"></html:password></td>
                   <td style="width:50%;" align="left"><div></div></td>
                </tr>
                <tr>
                   <td style="width:20%;" align="left"><b>Local Directory</b></td>
                   <td style="width:30%;" align="left"><html:text property="localDir" styleId="localdir"></html:text></td>
                   <td style="width:50%;" align="left"><div id="localdirdiv"><html:errors property="EmptyLocalDir"/></div></td>
                </tr>
                <tr>
                    <td colspan="3" align="center" >
                        <INPUT TYPE="BUTTON" VALUE="Previous" ONCLICK="window.location.href='newprovider.jsp'"/> 
                        <html:submit value="Next"></html:submit>
                        <INPUT TYPE="BUTTON" VALUE="Cancel" ONCLICK="window.location.href='AdminHome.jsp'"> 
                    </td>  
                </tr>
             </html:form> 
            </table>
           </body>
         </html>